package br.com.engine.audio;

import javax.media.Player;
import javax.media.Time;

import br.com.engine.resources.ResourceManager;

public class SimpleAudio 
{
	private Player  audioPlayer = null;
	private boolean bRunning    = false;
	
	public SimpleAudio( String nome )
	{
		audioPlayer = ResourceManager.loadResource( nome, ResourceManager.AUDIO, Player.class );
	}
	
	public SimpleAudio( String nome, int nTipo )
	{
		audioPlayer = ResourceManager.loadResource( nome, nTipo, Player.class );
	}
	
	public void play( ) 
	{
		audioPlayer.start( );
		bRunning = true;
    }

	public boolean isRunning( )
	{
		return bRunning;
	}
	
	public Time getMediaTime( )
	{
		return audioPlayer.getMediaTime();
	}
	
	public Time getDuration( )
	{
		return audioPlayer.getDuration( );
	}
	
    public void stop( )
    {
    	audioPlayer.stop( );
    	audioPlayer.close( );
    	bRunning = false;
    }
}